import * as actionTypes from "./constants";//改代码的意思是，
// 将 constants 中导出的值全部放在actionTypes对象中


import {Map} from "immutable";//使用immutable

const defaultState=Map({
  topBanners:[],
  hotRecommends:[],
  newAlbums:[],
})

function reducer(state=defaultState,action) {
  switch (action.type) {
    case actionTypes.CHANGE_TOP_BANNERS:
      return state.set("topBanners",action.topBanners);//使用set来放一个新的数据
    case actionTypes.CHANGE_HOME_RECOMMEND:
      return state.set("hotRecommends",action.hotRecommends);
    case actionTypes.CHANGE_NEW_ALBUM:
      return state.set("newAlbums",action.newAlbums);
    default:
      return state;
  }
}

export default reducer;
